//是否大于0
function ifGreaterThanZero(a) {
	if (a > 0 || a == 0) {
		return a
	} else if (a < 0) {
		return 0;
	} else {
		return 0;
	}

}

//字符串非空判断
function isNameStringNull(b) {

	if (b == null || b == undefined || b == '') {

		return '匿名';
	} else {
		return b;
	}

}

function tabswitch(index) {
	$('.indicator').attr('style', 'display:none;');
	$('.col').attr('style', 'color:#323232;');
	$('#col' + index).attr('style', 'color:#18b4ed;');
	$('#indicator' + index).attr('style', 'display:block;');
	$('.mui-control-content').removeClass('mui-active');
	$('#item' + index).addClass('mui-active');
	$('#indicator' + index).attr('style', 'display:block;');
	setTab("col", index);
}

function setTab(name, cursel) {
	for (var i = 1; i <= 2; i++) {
		var menu = document.getElementById(name + i);
		var con = document.getElementById("Tab" + i);
		con.style.display = i == cursel ? "block" : "none";
	}
}

//设置老师端头部chart图ui
function SetTeacherTopChartUI(legendArr, seriesArr, total) {
	var myChart = echarts.init(document.getElementById('top_chart'));
	var titleStr = total + "积分"
	myChart.setOption({
		title : {
			text : titleStr,
			x : '54%',
			y : '36%',
			textStyle : {
				fontWeight : 'normal',
				color : '#0580f2',
				fontSize : '12'
			}
		},
		tooltip : {
			trigger : 'item',
			formatter : "{d}% <n/>{a} <br/>{b} : {c}积分"
		},
		legend : {
			orient : 'vertical',
			x : 'left',
			selectedMode : false,
			left:10,
			borderRadius : 4,
			itemWidth : 12,
			itemGap : 12,
			itemHeight : 12,
			data : legendArr
		},
		series : [{
			name : '',
			type : 'pie',
			radius : ['40%', '55%'],
			center : ['60%', '40%'],
			color : ["#aa68da", "#06bcff ", "#66cccc", "#a3d146", "#f16bae", "#e15517", "#ff9900", "#fcdb00"],
			data : seriesArr,
			label : {
				normal : {
					show : false
				}
			},
			labelLine : {
				normal : {
					show : false
				}
			},
		}]
	});
}

//显示在html
function SetStudentListUI(list) {
	var len = list.length;
	var strhtml="";
	var data = "";
	for (var i = 0; i < list.length; i++) {
	    var num=(i+1)+(page-1)*row;
		data = list[i];
		
		var str='<li class="mui-table-view-cell mui-media">'+
			'<span class="rank-num mui-pull-left base_dark_grey base_tag_font">'+num+'</span>'+
			'<img class="mui-media-object mui-pull-left user-icon" src="'+HeadPortraitIsNull(data.picurl)+'">'+
			'<span class="user-name mui-pull-left base_dark_grey base_tag_font"> '+isNameStringNull(data.uname)+' </span>'+
			'<div class="mui-media-body a-p-right-div">'+
				'<p class="accmulate-point-title base_tag_font" style="line-height: 42px;">'+
					'<span class="accmulate-point-num"> '+ifGreaterThanZero(returnInt(data.points))+' </span>积分值'+
				'</p>'+
			'</div>'+
		'</li>';
		
		
		strhtml = strhtml + str;
	}
	if (page == 1) {
		$('#AccmulatePointsTableView').html(strhtml);
	} else {
		$('#AccmulatePointsTableView').append(strhtml);
	}
	
}
function returnInt(a) {
	if (a != null && a !== "" && a != undefined) {
		return parseInt(a);
	} else {
		return 0;
	}
}
	//设置年份ui
function setYearUi(index,year){
		
  if(index==1){
   return  '<li class="guijiLi yearItem'+index+'"  >'+
			'<div class="clearfix guijiItemHd">'+
				'<div class="year">'+
					'<span class="year_title">'+year+'</span>'+
				'</div>'+
			'</div>'+
			'<div class="month_list " id="monthItem'+year+'" style="display: block;">'+
	
			'</div>'+
		'</li>';
}else{
 return  '<div class="line_fenge_div">'+
			'<div class="line_fenge_left"></div>'+
			'<div class="line_fenge_right"></div>'+
		'</div>'+
		'<li class="guijiLi yearItem'+index+'"  >'+
			'<div class="clearfix guijiItemHd">'+
				'<div class="year">'+
					'<span class="year_title">'+year+'</span>'+
				'</div>'+
			'</div>'+
			'<div class="month_list " id="monthItem'+year+'" style="display: block;">'+
	
			'</div>'+
		'</li>';
}
				
}

		//设置月份ui
function setMonthUi(index, data,year) {			  
  return   '<div class="line_fenge_div">' +
				'<div class="line_fenge_left"></div>' +
				'<div class="line_fenge_right"></div>' +
			'</div>' +
			'<div class="guijiItemBd_month " >' +
				'<div class="clearfix guijiItemHd_month" >' +
					'<div class="month">' +
						'<span class="month_title">' + data.month + '月</span>' +
					'</div>' +
				'</div>' +
				'<div class="day_list" id="dayItem'+data.month+year+'" style="display: block;"></div>' +
			'</div>';		  	  
}
	//设置日期ui
function setDayUI(index,chapterData,month){
	  var dateStr=month+"月"+chapterData.day+"日";
  var hourStr="";
  
  hourStr='<div class="hour_list" id="hourItem'+chapterData.day+month+'" style="display: block;"></div>';
  return  '<div class="guijiItemBd_day ">'+
				 '<div class="clearfix guijiItem 2017 guijiItemHd_day " >'+
					 '<div class="yuefen left"></div>'+
					 '<div class="guiji left">'+
					   '<span class="guiji_dian"></span>'+
						'<div class="day">'+
						   '<span class="day_title">'+dateStr+'</span>'+
						'</div>'+
					 '</div>'+
				'</div>'+
				hourStr+
	    '</div>'
}
	//设置小时ui
function setHourUI(index,day,data){
 var vnameStr;//章节名称
 var pointsStr;//积分
 var operationStr=data.operation;//动作
 var actionStr;
 var oneStr;
 var messageStr;
 var cnameStr;
 var cname;
 if(isEmpty(data.action)){
   actionStr="";
 }else{
   actionStr="【"+data.action+"】";
 }
 if(isEmpty(data.vname)){
   vnameStr="";
 }else{
    if(data.types==15){//公共课程部分
      vnameStr="";
    }else{
      vnameStr=data.vname;
    }
 }
 if(data.points==0){
   pointsStr="";
 }else{
   pointsStr=judgePointsPositiveAndnegative(parseInt(data.points))+'积分';
 }
 if(isEmpty(data.message)){
   messageStr="";
 }else{
   if(data.types==4||data.types==10){//学生端答疑部分和笔记部分
       messageStr=data.message;
     }else{
      messageStr='-'+data.message;
   }
 }
 if(isEmpty(data.cname)){
   cname="";
 }else{
   if(data.types==18){//老师端提问答疑
    cname=data.pname+'-'+data.cname;
   }else{
   cname=data.cname;
   }
 }
 
 if(data.types!=13){
	 cnameStr=cname;
	 if(pointsStr!=0){
	 oneStr=(operationStr+actionStr+vnameStr+messageStr)+',';
	 }else{
	  oneStr=(operationStr+actionStr+vnameStr+messageStr);
	 }
	 
 }else{//认证部分
	 oneStr=data.message;
	 cnameStr=cname
 }

 return '<div class="clearfix guijiItem 2017">'+
			'<div class="yuefen left">'+
				'<p class="yu_date">'+
					timeWithStamp5(data.instime)+
				'</p>'+
			'</div>'+
			'<div class="guiji left">'+
			   '<span class="guiji_dian"></span>'+
				'<div class="sanjiao"></div>'+
				'<div class="tuijiDiv">'+

                    '<div style="float: left;width: 100%">'+
				      '<p class="tuiji_info ">'+
				      oneStr+
				       '<span class="jifenSpan">'+pointsStr+'</span>'+
				      '</p>'+
				      '<p class="tuiji_info ">'+
				    cnameStr+
				      '</p>'+

				    '</div>'+
//						    '<div style="float: left;width: 22%;margin-top: 2px;">'+
//						        '<span class="jifenSpan">'+pointsStr+'</span>'+
//						    '</div>'+
				   
		        '</div>'+
		   '</div>'+
	  '</div>';
}
	//字符串截取10位
function notThirteen(b) {
		var str = b;
	
		if (str.length > 16) {
			b = str.substr(0, 15) + '...';
			return b
		} else {
			return b
		}
    }